function diff = phi_fun( G, region, param)
   
    if strcmp(region, 'N')
        gamma_1=param.gamma_N_1;
        gamma_2=param.gamma_N_2;
    elseif strcmp(region, 'R') 
        gamma_1=param.gamma_R_1;
        gamma_2=param.gamma_R_2;    
    end
    
    diff = 1./rho_fun(1,region,param).*(1 - theta_fun(G,region,param)./gamma_1-(1-theta_fun(G,region,param))./gamma_2);

end